<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>弓友之家</title>
    <link rel="stylesheet" href="css/mui.css" />
    <link rel="stylesheet" href="fonts/iconfont.css" />
    <link rel="stylesheet" href="css/style.css" />
</head>
<body class="bg1">
	<div class="mui-content" style="overflow: hidden;">
		<div class="logo"><img src="images/logo_w.png"/></div>
		<form class="login">
			<div class="item mui-clearfix"> 
				<label><i class="iconfont icon-gerenzhongxin"></i></label>
				<input type="number" id="mobile" placeholder="输入您的手机号" />
			</div>
			<div class="item mui-clearfix">
				<label><i class="iconfont icon-mima"></i></label>
				<input type="password" id="psw" placeholder="输入您的登录密码" />
			</div>
			<div class="item mui-clearfix">
				<label><i class="iconfont icon-mima"></i></label>
				<input type="password" id="psw1" placeholder="确认您的登录密码" />
			</div>
			<div class="button">
				<button type="button" onclick="register()" class="on">完善信息</button>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="js/jquery-1.8.3.min.js" ></script>
	<script type="text/javascript" src="js/mui.min.js" ></script>
	<script type="text/javascript" src="js/common.js" ></script>
	<script type="text/javascript" charset="utf-8">
      	mui.init();
      	var open_id="";
      	mui.plusReady(function(){
      		var _self=plus.webview.currentWebview();
      		open_id=_self.open_id;
      	})
		var myreg =/^1[3|4|5|7|8][0-9]{9}$/; 
      	function register(){
      		var mobile=$("#mobile").val();
      		if(!myreg.test(mobile)||mobile==""){
				mui.toast("请输入正确的手机号");
				return false;
			}
	      	var psw=$("#psw").val();
	      	var psw2=$("#psw1").val();
	      	if(psw==""||psw2==""){
	      		mui.toast("密码不能为空");
				return false;
	      	}
	      	if(psw!=psw2){
	      		mui.toast("两次密码不同，请检查");
				return false;
	      	}
	      	mui.ajax(H_SRC+'/amier/index/msg_refine',{
				data:{
					mobile:mobile,
					password:psw,
					open_id:open_id
				},
				dataType:'json',
				type:'post',
				timeout:10000,
				success:function(data){
					if(data.code==1){
						mui.toast("完善信息成功，请登录");
						set("token", data.token);
						mui.openWindow({
							url:'index.html',
							id:'index.html',
							createNew:true,
							show: {
								autoShow: true,
								aniShow: 'slide-in-right',
								duration: 200
							}
						})
						setTimeout(function(){
						    mui.currentWebview.close('none');
						},500);
					}else{
						mui.toast(data.msg);
					}
				},
				error:function(xhr,type,errorThrown){
					mui.toast(type)
				}
			}) 
     	}
    </script>
</body>
</html>